package com.atguigu.gmall.all.controller;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.client.ProductFeignClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author Fxz
 * @version 1.0
 * @date 2022-02-11 22:28
 */
@Controller
@RequiredArgsConstructor
public class IndexController {

	private final ProductFeignClient productFeignClient;

	@RequestMapping("/")
	public String index(HttpServletRequest request) {
		Result<List<JSONObject>> result = productFeignClient.getBaseCategoryList();
		request.setAttribute("list", result.getData());
		return "index/index";
	}

}
